<%@page import="databank.DataBankVo"%>
<%@page import="databank.DataBank"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>modify.jsp</title>

<script>
function getId(id){return document.getElementById(id)}

function init(){
	getId('btnlist').onclick=function(){
		location.href='MyHome.jsp?inc_content=./databank/list.jsp';
	}
	getId('btndel').onclick=fileDel();
}

function fileDel(serial, filename){
	var f = confirm("첨부 파일을 정말 삭제하시겠습니까???");
	if(f){
		location.href='MyHome.jsp?inc_content=./databank/delete_result.jsp&serial='serial + "&filename="+filename;
	}else{
		alert("삭제가 취소되었습니다.");
	}
}


</script>

</head>

<body>
<jsp:useBean id="bankVo" class="databank.DataBankVo" scope="page"/>
<jsp:setProperty property="*" name="bankVo"/>
<%
DataBank bank = new DataBank();
bank.setVo(bankVo);
DataBankVo vo = bank.view();

%>



<center>
<form action="MyHome.jsp?inc_content=./databank/modify_result.jsp" method='post' enctype='multipart/form-data'>
<table border=1>
	<tr>
		<td colspan=2 align=center><h3>파일 수정 폼</h3></td>
	<tr>
		<td>작성자:</td><td><input type='search' name='mid' value='<%=vo.getMid()%>'></td><br>
	</tr>
	<tr>
		<td>제목 :</td><td><input type='search' name='subject' value='<%=vo.getSubject()%>'></td><br>
	</tr>
	<tr>
		<td>내용:</td><td><textarea name='content' rows='8' cols='68' name='content'><%=vo.getContent()%></textarea></td><br>
	</tr>
	<tr>
		<td>파일명:</td>
		<td>
		<%if(vo.getFilename() == null || vo.getFilename().equals("")){%>
		<input type='file' name='newfilename'>		<!--  insert의 filename을 newfilename으로 변경 -->
		<%}else{%> 
			<label name='filename'><%=vo.getFilename()%></label>
			<input type='button' value='삭제' onclick="fileDel(<%=vo.getSerial()%>,'<%=vo.getFilename()%>')">
		<%}%>
		</td><p/>
	</tr>
	<tr>
		<td>암호:</td><td><input type='password' name='pwd'></td><p/>
	</tr>
	<tr>
		
		<td colspan=2 align=center>
			<input type='button' value='목록' id='btnlist'>
			<input type='submit' value='수정'>
			<input type='hidden' name='serial' value='<%=vo.getSerial()%>'>
		</td>
	</tr>
		
</table>

</form>
</center>
<script>init();</script>
</body>
</html>